/* eslint-disable vue/no-parsing-error */
/* eslint-disable vue/html-quotes */
<template>
  <div class="header">
    <div class="section">
      <div class="con1">
        <div class="imgBox">
          <img :src="headerObj.logoImg" alt="logo" @click="goHome">
        </div>
        <div class="search-container">
          <div class="search-box">
            <div class="serch-left">
              <!-- <input v-model="searchData" type="search" :placeholder="'大家都在搜：'+ hotWord.slice(0,3).toString()" max="10"> -->
              <input v-model="searchData" type="search" placeholder="请输入您要搜索的内容" max="10">
            </div>
            <button class="search-button" @click="goList">搜索</button>
          </div>
          <ul>
            <li v-for="(item,index) in hotWord" :key="index" @click="hotSearch(item)">{{ item }}</li>
          </ul>
        </div>
        <p>财富热线：66666666</p>
      </div>

      <div class="nav-line">
        <nav class="nav-box">
          <ul class="tab-switch-box">
            <router-link v-for="(item,index) in navList1" :key="index" tag="li" :to="{path:theRouter[index]}" :exact="index==0?true:false">
              {{ item.name }}
              <div v-if="item.childs" class="liChild">
                <router-link v-for="(cItem,cIndex) in item.childs" :key="cIndex" tag="p" :to="{path:routerChilds[cIndex]}">{{ cItem }}</router-link>
                <!-- <p v-for="(cItem,cIndex) in item.childs" :key="cIndex" @click="goTo(index)">{{ cItem }}</p> -->
              </div>
            </router-link>
          </ul>
          <div v-if="loginBool" class="user login-box">
            <div class="news-box" @click="userMsg">
              <i class="font_family iconindex_icon_bell" />
              <span>2</span>
            </div>
            <span>|</span>
            <img src="../../../assets/img/template-item2/user/user.png">
            <span class="userCenter" @click="toUser">个人中心</span>
            <span>|</span>
            <span class="out" @click="out">退出</span>
          </div>
          <div v-else class="user user-self">
            <button @click="login">登录</button>
            <button @click="register">注册</button>
          </div>
        </nav>
      </div>

    </div>
  </div>
</template>

<script>
// import {mapState} from "vuex"
export default {
  props: {
    headerObj: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      /* header */
      hax: true,
      choseBool: true,
      theRouter: ['/vMain', '/brand', '/vMain/allBrand', '/vMain/join', '/vMain/strength', '/vMain/news', '/vMain/about'],
      routerChilds: ['/vMain/allBrand/tuijian', '/vMain/allBrand'],
      navList1: [
        {
          name: '首页',
          childs: null
        },
        {
          name: '十大品牌',
          childs: null
        },
        {
          name: '品牌大全',
          childs: ['品牌推荐', '品牌大全']
        },
        {
          name: '招商加盟',
          childs: null
        },
        {
          name: '榜上力量',
          childs: null
        },
        {
          name: '新闻资讯',
          childs: null
        },
        {
          name: '关于我们',
          childs: null
        }
      ],
      hotWord: ['回力', '三叶草', '乔丹', '匡威', '李宁', '阿迪达斯', '三叶草', '乔丹', '匡威', '李宁'],
      searchData: ''
    }
  },
  /* computed:mapState({
    dddd:state => state.upLogin
      //console.log(this.$store.state.upLogin,123)
  }), */
  computed: {
    loginBool() {
      return this.$store.state.upLogin
    }
  },
  created() {

  },
  methods: {
    login() {
      this.$router.push('/login')
    },
    register() {
      this.$router.push('/register')
    },
    goList() {
      this.$router.push({ path: '/vMain/searchList', query: { hasMsg: this.searchData }})
    },
    hotSearch(item) {
      this.searchData = item
      this.$router.push({ path: '/vMain/searchList', query: { hasMsg: this.searchData }})
    },
    out() {
      this.$store.commit('changeLogin', false)
    },
    toUser() {
      this.$router.push('/vMain/newpersonage')
    },
    userMsg() {
      this.$router.push('/vMain/newpersonage/msg')
    },
    goHome() {
      this.$router.push('/vMain')
    },
    goTo(num) {
      console.log(num, 11111)
      // this.$router.push(this.routerChilds[num])
    }
  }

}
</script>

<style lang="scss" scoped>
.header{
  height: 208px;
  width: 100%;
  min-width: 1200px;
  background-color: #fff;
  >.section{
    width: 100%;
    margin: 0 auto;
    padding-top: 40px;
    >.con1{
      width: 1200px;
      margin: 0 auto;
      height: 108px;
      color: #B8B8B8;
      font-size: 14px;
      display: flex;
      flex-flow: row nowrap;
      justify-content: space-between;
      align-items: flex-start;
      /* &::after{
        display:block;clear:both;content:"";visibility:hidden;height:0
      } */
      >.imgBox{
        height: 69px;
        width: 320px;
        >img{
          height: 59px;
          cursor: pointer;
        }

      }
      >.search-container{
        width: 586px;
        height: 72px;
        margin-right: 69px;
        >.search-box{
          width: 100%;
          height: 46px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-start;
          align-items: center;
          margin-bottom: 9px;
          color: #B8B8B8;
          >.serch-left{
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            align-items: left;
            border: 1px solid #ECECEC;
            >input{
              border: none;
              width: 486px;
              height: 44px;
              padding-left: 11px;
              border-radius: 6px;
            }
            input::-webkit-input-placeholder {
              /* 修改placeholder颜色  */
              color: #B8B8B8;
              font-size: 18px;
            }
          }
          >.search-button{
            color: #fff;
            background-color: #DC3535;
            border: none;
            border-radius: 0;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
            width: 100px;
            height: 46px;
            line-height: 46px;
            font-size: 22px;
          }
        }
        >ul{
          font-size: 14px;
          color: #B8B8B8;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-start;
          align-items: center;
          >li{
            cursor: pointer;
            text-align: center;
            padding: 0 12px;
            border-right: 1px solid #B8B8B8;
            font-size: 14px;
            color: #B8B8B8;
          }
          >li:first-child{
            padding-left: 0;
          }
          >li:last-child{
            border-right: 0;
          }
        }
      }
      >p{
        width: 199px;
        color: #333;
        font-size: 18px;
        padding-top: 10px;
        font-weight: bold;
      }

    }
    >.nav-line{
      max-width: 1920px;
      min-width: 1200px;
      background-color: #2B2D42;
      color: #fff;
      font-size: 20px;
      height: 60px;
      line-height: 60px;
      margin: 0 auto;
      display: flex;
      flex-flow: row nowrap;
      justify-content: space-between;
      align-items: center;
      >.nav-box{
        width: 1200px;
        margin: 0 auto;
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
        >.tab-switch-box{
          width: 900px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-start;
          align-items: center;
          font-size: 20px;
          >li{
            position: relative;
            height: 60px;
            line-height: 60px;
            width: 126px;
            text-align: center;
            cursor: pointer;
            >.liChild{
              display: none;
              position: absolute;
              bottom: -101px;
              left: 0;
              z-index: 99;
              width: 100px;
              padding: 16px 0;
              background-color: #fff;
              //background-color: rgb(107, 194, 197);
              font-size: 14px;
              color: #333;
              >p{
                text-align: center;
                height: 34px;
                line-height: 34px;
              }
              >p:hover{
                background-color: #417AEF;
                color: #fff;
              }
            }
          }
          >li:hover{
            >.liChild{
              display: block;
            }
          }
          >.router-link-exact-active{
            background-color: #DC3535;
          }
          >.router-link-active{
            background-color: #DC3535;
          }
        }
        >.user{
          float: right;
          width: 194px;
          height: 28px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: space-between;
          align-items: center;
          >.userCenter{
            cursor: pointer;
          }
          >.out{
            cursor: pointer;
          }
        }
        >.login-box{
          padding-top: 11px;
          >.news-box{
            position: relative;
            cursor: pointer;
            >i{
              font-size: 25px;
            }
            >span{
              display: block;
              width: 18px;
              height: 18px;
              line-height: 18px;
              border-radius: 50%;
              text-align: center;
              background-color: #417AEF;
              color: #fff;
              position: absolute;
              top: -5px;
              right: -4px;
            }

          }
        }
        .user-self{
          width: 120px;
          font-size: 12px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-end;
          align-items: center;
          >button{
            background: transparent;
            color: #fff;
            font-size: 20px;
            line-height: 1;
            padding: 0;
            cursor: pointer;
          }
          >button:nth-child(2){
            width: 53px;
            text-align: right;
            border-left: 1px solid #fff;
            margin-left: 9px;
          }
        }

      }

    }
  }
}
</style>

